﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DatabaseModule
{
    //Interface to abstract standard interactions with a database
    public interface DAO
    {
        //For debug use: when set to true, all SQL statements are printed to the console
        void SetVerboseMode(bool mode);


        //Test that the database connection can be established
        bool TestConnection();


        //Data Accessor Functions

        //Retrieve a single value from the database
        string GetValue(string table, string field, KeyValues keysAndVals);

        //Retrieve the first row of results from the database
        Dictionary<string, string> GetRow(string table, string[] fields, KeyValues keysAndVals);

        //Retrieve all results from the database
        List< Dictionary<string, string> > GetRows(string table, string[] fields, KeyValues keysAndVals, int limit = 0);


        //Data Mutator Functions

        //Insert a new row into the database
        bool InsertRow(string table, KeyValues fieldsAndVals);

        //Update the value(s) of certain field(s) in any rows where key(s) match value(s)
        bool UpdateRows(string table, KeyValues keysAndVals, KeyValues fieldsAndVals);

        //Delete rows where key(s) match value(s)
        bool DeleteRows(string table, KeyValues keysAndVals);


        //Function to access the last error (if any) that ocurred
        string GetLastError();
    }
}
